package com.itheima.exception;

import com.itheima.utils.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandle {

    @ExceptionHandler(Exception.class)
    public Result<String> exception(Exception exception) {
        exception.getMessage();
        return Result.error("服务器走丢了，请稍后再来");
    }

    @ExceptionHandler(BusinessException.class)
    public Result<String> busException(BusinessException bsi) {
        String message = bsi.getMessage();
        return Result.error(message);
    }

}
